package com.allinone.controller;

import java.util.List;
import java.util.UUID;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.allinone.domain.User;
import com.allinone.service.UserService;

@RestController
public class TestController {
	@Autowired
	private UserService userService;
	
	@RequestMapping(value="/listUsers",produces="application/json;charset=utf-8")
    public List<User> listUsers() {
        return userService.listUsers();
    }
	
	@RequestMapping("/uid")
    String uid(HttpSession session) {
        UUID uid = (UUID) session.getAttribute("uid");
        if (uid == null) {
            uid = UUID.randomUUID();
        }
        session.setAttribute("uid", uid);
        return session.getId();
    }
}
